package card;

import place.Landindex;
import PJ.Entrance;
import PJ.Player;

public class LandCard extends CardSystem {
	//土地卡
	String name="LandCard";
	String function="若停留在其他人的土地所在地，可以在缴纳过路费后将该土地免费据为己有；若停留在无主土地直接据为己有，持续五回合。";	
	String type="MagicCard";
	String range="自己";
	LandCard(){
		int point=40;
		this.point=point;
	}	
	@Override
	public String getName() {
		
		return name;
	}

	@Override
	public String getFunction() {
		// TODO Auto-generated method stub
		return function;
	}

	@Override
	public String getType() {
		// TODO Auto-generated method stub
		return type;
	}
	@Override
	public int getPoint() {
		return point;
	}
	@Override
	public String getRange() {
		// TODO Auto-generated method stub
		return range;
	}
	@Override
	public void print(int location, int namei) {
		// TODO Auto-generated method stub
		Player playerow=new Player();
		Player player=new Player();
		for(int i=0;i<Entrance.players.size();i++){
			if(Entrance.players.get(i).getNamei()==Landindex.mark[location].owner){
				playerow=Entrance.players.get(i);
			}
			if(Entrance.players.get(i).getNamei()==namei){
				player=Entrance.players.get(i);
			}
		}
		if(Landindex.mark[location].owner==0){
			Landindex.mark[location].owner=namei;
			player.setHousequantity(player.getHousequantity()+1);
			player.setHouseValue(player.getHouseValue()+Landindex.mark[location].price);
			System.out.println("卡牌使用成功，这块无主土地免费归您了");
		}else if(Landindex.mark[location].owner!=namei){
			playerow.setHousequantity(playerow.getHousequantity()-1);
			playerow.setHouseValue(playerow.getHouseValue()-Landindex.mark[location].price);
			Landindex.mark[location].owner=namei;
			player.setHousequantity(player.getHousequantity()+1);
			player.setHouseValue(player.getHouseValue()+Landindex.mark[location].price);
			System.out.println("卡牌使用成功，这块土地被您抢走了");
		}else{
			System.out.println("卡牌使用失败，您在您的土地上浪费了一张土地卡");
		}
	}
}

